package com.foreknow.elmboot.mapper;

import com.foreknow.elmboot.po.Cart;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CartMapper {

    /**
     * 查询购物车中的信息
     * @param cart
     * @return
     */
    public List<Cart> listCart(Cart cart);


    /**
     *添加数据
     * @param cart
     * @return
     */
    @Insert("insert into cart(foodId,businessId,userId,quantity) values(#{foodId},#{businessId},#{userId},1)")
    public int addCart(Cart cart);


    /**
     * +1后更新数据
     * @param cart
     * @return
     */
    @Update("update cart set quantity=#{quantity} where userId=#{userId} and businessId=#{businessId} and foodId=#{foodId}")
    public int updateCart(Cart cart);

    /**
     * 删除数据
     * @param cart
     * @return
     */
//    @Delete("delete from cart where businessId=#{businessId} and userId=#{userId} and foodId=#{foodId}")写在配置文件中了
    public int deleteCart(Cart cart);


}
